package com.metamedia.test;

public abstract class Operation {
	public abstract Double compute();

	public abstract String getName();

	public static Operation getOperation(String operation, double... numbers) {
		if (operation.equalsIgnoreCase("sum"))
			return new Sum(numbers);
		else if (operation.equalsIgnoreCase("min"))
			return new Min(numbers);
		else if (operation.equalsIgnoreCase("max"))
			return new Max(numbers);
		else if (operation.equalsIgnoreCase("average"))
			return new Average(numbers);
		else
			return null;
	}

	@Override
	public String toString() {
		return getName() + " " + compute();
	}
}
